<html><body>
<h2>Simile Timeline Rails Helper Example</h2>
<h3>In the Model</h3>

<pre>
acts_as_simile_timeline_event(
  :fields => {
    :start       => :shipped_on,
    :title       => :title,
    :description => :description,
  }
)
def title
  "#{product.name} to #{recipient.name}"
end
def description
  "#{product.description} shipped on #{shipped_on} to #{recipient.name}, #{shipping_class} with shipping charges of #{charges}"
end
</pre>

<h3>In the Controller</h3>
<pre>
def recent
  @shipping_logs = ShippingLog.find(:all, :conditions => [ "shipped_on > ? AND shipped_on < ?", params[:start].to_time, params[:end].to_time ] )
  render :partial => 'timeline_json'
end
</pre>

<h3>The View (simplified)</h3>
<pre>
&lt;head>
&lt;%= javascript_include_tag 'http://simile.mit.edu/timeline/api/timeline-api.js' -%>
&lt;%= javascript_include_tag 'prototype' -%>
&lt;style type="text/css">
.default_timeline { width: 400px; height: 250px; }
&lt;/style>
&lt;/head>
&lt;body>
&lt;%
  shipping_logs_timeline = ::Simile::Timeline::Timeline.new(
    :name        => "ShippingLogs",
    :event_source => {
        :controller => 'shipping_logs',
        :action     => 'recent'
      },
    :event_band   => :days,
    :bands       => {
      :months => {
        :trackGap       => '0.1',
        :showEventText  => 'false',
        :width          => '"8%"',
        :intervalUnit   => 'Timeline.DateTime.MONTH',
        :intervalPixels => '600'
      },
      :days => {
        :trackGap       => '0.1',
        :showEventText  => 'false',
        :width          => '"8%"',
        :intervalUnit   => 'Timeline.DateTime.DAY',
        :intervalPixels => '600'
      },
      :hours => {
        :width          => '"84%"',
        :intervalUnit   => 'Timeline.DateTime.HOUR',
        :intervalPixels => '200'
      }
    },
    :bands_order => [ :months, :days, :hours ],
    :synchronize => {
      :months => :hours,
      :days   => :hours
    },
    :highlight => [ :months, :days ]
  )

%>

&lt;%= simile_timeline(shipping_logs_timeline, { :class => 'default_timeline' } ) %>

&lt;/body>
</pre>